var _api = _interopRequireDefault(require("../../utils/api")), _config = _interopRequireDefault(require("../../utils/config"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var VERSION_KEY = "minicard.last.version", SORT_NUM = [ "一", "二", "三", "四", "五", "六", "七" ], MINICARD_TYPE = 1, version = "";

Component({
    data: {
        isshown: !1,
        SORT_NUM: SORT_NUM,
        seconds: 3
    },
    ready: function() {
        var i = this;
        version || wx.nextTick(function() {
            _api.default.version.lists({
                data: {
                    type: MINICARD_TYPE,
                    limit: 1
                }
            }).then(function(e) {
                var t = e.data.list;
                return i.checkVersion(t[0]);
            });
        });
    },
    methods: {
        checkVersion: function(t) {
            var i = this;
            if (t) {
                var n = t.version;
                version = n, wx.getStorage({
                    key: VERSION_KEY,
                    complete: function(e) {
                        e.data !== n && (wx.setStorage({
                            key: VERSION_KEY,
                            data: n
                        }), i.versionShown(t));
                    }
                });
            }
        },
        versionShown: function(e) {
            var t = e.version, i = e.content;
            this.setData({
                version: t,
                isshown: !0,
                appName: _config.default.appName,
                log: JSON.parse(i)
            }), this.counter();
        },
        counter: function() {
            var t = this;
            wx.setTimeout(function() {
                var e = t.data.seconds - 1;
                t.setData({
                    seconds: e
                }), e && t.counter();
            }, 1e3);
        },
        colseDialog: function() {
            this.data.seconds || this.setData({
                isshown: !1
            });
        }
    }
});